<template>
  <div></div>
</template>
<script>
  import { mapGetters } from "vuex";
  export default {
    computed: {
      ...mapGetters(["turing","userInfo"])
    },
    data() {
      return {
        turingkey: "",
        turingid: "",
        phone: "",
        // uid: "",
        client:'',
      };
    },
    created() {
      this.turingid = this.turing.turingid
      this.turingkey = this.turing.turingkey

      var ua = navigator.userAgent.toLowerCase();
      if (/android|adr/gi.test(ua)) {
        this.client='android';
      }else if(/\(i[^;]+;( U;)? CPU.+Mac OS X/gi.test(ua)){
        this.client='iphone';
      }

      this.phone = this.userInfo.phone;
      // this.uid = this.userInfo.uid;
      if (this.turingkey && this.turingid) {
          if (this.phone) {
            location.replace(
              `http://iot-ai.tuling123.com/jump/app/source?apiKey=${this.turingkey}&uid=${this.phone}&client=${this.client}`
            );
          } else {
            this.$router.push("bindphone");
          }
      } else {
        this.$router.push("binding/device");
      }

      // window.href=('http://iot-ai.tuling123.com/jump/app/source?apiKey=xxx&uid=手机号&client=android')
    }
  };
</script>
